package leetcode.sword;

public class Solution56_2 {

    public int singleNumber(int[] nums) {

        int A = 0, B = 0;

        for (int num : nums) {
            int tmpA = ~A&B&num | (A&(~B)&(~num));
            int tmpB = A&(~B)&(~num) | (~A&(~B)&num);
            A = tmpA;
            B = tmpB;
        }

        return B;
    }
}
